﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GroupItem : MonoBehaviour
{
    public Text groupName;
    public UGUIToggle toggle;
    public SelectGroupPanel groupPanel;

    private Data.ActionGroup groupData;
    private bool select = false;
    public bool GetSelect()
    {
        return select;
    }
    public void SetData(Data.ActionGroup data)
    {
        this.groupData = data;
        groupName.text ="GroupId:"+groupData.GroupNum+" - "+ groupData.Desc;
        toggle.onValueChangedEvent = OnToggle;

        if (data == EActionDataCtr.Instance.CurGroupData())
        {
            toggle.isOn = true;
        }
    }
    public Data.ActionGroup GetData()
    {
        return groupData;
    }
    public void OnToggle(object obj,bool value)
    {
        if (value == true)
        {
            this.select = value;
        }
    }

    public void DelateGroup()
    {
        if (EActionDataCtr.Instance.GetGroupList().Count <= 1)
        {
            return;
        }
        groupPanel.DelateGroup(groupData);

        EActionDataCtr.Instance.DelateGroup(groupData);
        //DelateEvent

        EventManager.TriggerEvent(CommonEvent.DelateActionGroup);
    }
}
